function saveForm() {
    debugger
    const self = this;
    const formPartEle = self.$$("form_part_8nenvo");
    const formRenderEle = formPartEle.$$getRenderElement();

    if (formRenderEle) {
        formRenderEle.onSave().then((res) => {
            if (res && res.result) {
                console.log("保存成功", res);
                formPartEle.dataKey.documentNo ="";
                formPartEle._documentNo = "";
                formPartEle.$$loadData(res.result.documentNo);
            }
        });
    }
}

// 根据当前登陆人获取登陆人所在的部门区划
// 根据部门区划获取当前区划内的司法单位


function saveForm() {

    const self = this;
    const formPartEle = self.$$("form_part_8nenvo");
    const formRenderEle = formPartEle.$$getRenderElement();
    const confidscatedCardNumber = self.$$("text_input_fr4lav").cValue;
    const regionCode = confidscatedCardNumber.substring(0, 2);
    const lawEnforcementCode = confidscatedCardNumber.substring(2, 4);
    const currentSequenceCode = confidscatedCardNumber.substring(4, 8);
    const currentSequence = currentSequenceCode.replace(/^0+/, '');

    const formattedCardNumber = `${part1} ${part2} ${part3WithoutLeadingZeros}`;
    console.log(formattedCardNumber);  // 输出格式化后的字符串
    if (formRenderEle) {
        formRenderEle.onSave().then((res) => {
            if (res && res.result) {
                console.log("保存成功", res);
                updateLawConfiscatedCardInfo(regionCode, lawEnforcementCode, currentSequence)
                let pageRenderElement = self.$$root().$parent.$parent.$parent;
                pageRenderElement.goHistory(-1);
            }
        });
    }
}


/**
 * 保存成功后将当前的证件号的序列号更新到表中
 */
function updateLawConfiscatedCardInfo(regionCode, lawEnforcementCode, currentSequence) {

    return api.EXEC_FORMULA(
        "UPDATE('ds_tbl:t_50c0a039d1274a2b83d2ba0029107055', QUERY_AND(QUERY_EQ('region_code','" + regionCode + "'), QUERY_EQ('manage_unit_code','" + lawEnforcementCode + "')), '', ['current_sequence', '" + currentSequence + "'])"
    ).then(function (updateRes) {
        console.log('Update result:', updateRes);

    });
}


